import java.util.*;

public class Enemy extends Character {

  Random r = new Random();

  ArmorRetriever ar;
  public Enemy() {
    baseHP = 25;
    baseFoc = 20;
    myHP = 25;
    myFoc = 20;
    ar = new ArmorRetriever();
    equip(ar.getRandBody());
    equip(ar.getRandShoes());
    equip(ar.getRandHelm());
    equip(ar.getRandPants());
    equip(ar.getRandAccessory());
    equip(ar.getRandGloves());
    equip(ar.getRandWeapon());
  }


  public void act(Player p) {
    int num;
    if ((1.0*myHP)/(1.0*baseHP) <= .2) {
      if (r.nextInt(4) == 3 && this.numHPPots > 0) {
        useHPPotion();
        return;
      }
      num = r.nextInt(3);
      if (num == 2) {
        if (!useAbility("Heal", this)) {
          this.attack(p);
        }
        return;
      }
      if (num == 1) {
        this.attack(p);
      }
    }
    else {
      num = r.nextInt(3);
      if (num == 2 || num == 1) {
        this.attack(p);
      }
       else {
        num = r.nextInt(1000);
        if(num == 1000) {
          if(!useAbility("Instakill",p)) {
            this.attack(p);
          }
          return;
        }
        if (num <= 333) {
          if(!useAbility("Lightning",p)) {
            this.attack(p);
          }
          return;
        }
        else {
          if(!useAbility("Fire",p)) {
            this.attack(p);
          }
          return;
        }
      }
    }
  }
}

